_require "../../../basis.smi"
_require local "../../../smlnj-lib/Util/parser-comb.smi"
_require local "./FORMAT_EXPRESSION.sig"
_require local "./FormatExpressionTypes.smi"

structure FormatExpression =
struct

  datatype priority =
           Preferred of int
	 | Deferred
  datatype assocDirection =
           Left
         | Right
         | Neutral
  type assoc =
       {
        cut : bool,
        strength : int,
        direction : assocDirection
       }
  datatype expression =
           Term of (int * string)
         | Newline
         | Guard of (assoc option) * (expression list)
         | Indicator of
           {
            space : bool,
	    newline :
            {
             priority : priority
            }
		option
           }
         | StartOfIndent of int
         | EndOfIndent
         | Sequence of expression list
  val isHigherThan : priority * priority -> bool
  val assocToString : assoc -> string
  val priorityToString : priority -> string
  val toString : expression -> string
  val parse
      : (char, 'a) StringCvt.reader -> (expression list, 'a) StringCvt.reader
 
end
